home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
searchtools
/
getobjs
< prev
next >
Wrap
Text File
|
1994-08-01
|
3KB
|
116 lines
#! /bin/sh
# ~4Dgifts/toolbox/searchtools/getobjs library function INDEX creator
#
if [ $# -lt 1 ]
then echo Usage: $0 topdirectory; exit 1
fi
if [ ! -d $1 ]
then echo Usage: $0 topdirectory "(\"$1\" is not a directory)"; exit 1
fi
# Create an index to be used by the 'look' program that does a binary
# search on the first field (should be used with the -f (case insensitve)
# option. The output file is called "INDEX", and # is placed in the
# current directory.
# used to create an index of programs/files that use 'interesting'
# functions that people might want to look at as examples
# See the references to '$HOME/skipfuncs' for the method of
# eliminating uninteresting functions
# with relocatable objects (.o's), we can figure out which file
# referenced what. With binaries (programs, dynamic executables)
# we can't tell which file that went into it used it, so we
# make 2 passes, one for each kind, with a slightly different
# sed script. Of course, with .o's, the externals may be
# elsewhere in the same program. That's life. The other disadvantage
# with the .o's is that we lose the full pathname, since we get the
# name of the original file out of the header. But we have a hack
# for that also!
# so if the filename doesn't have a suffix (.c, .c++, etc.), then
# it is the executable, and you may have to look at the Makefile
# to see which files to check, but this is seldom much of a problem.
# this prepends the filename to each object
# ANSI 'reserved for system use' names like __stuff or _ABC are skipped.
# The final substitute, ending with 'p', reverses the fields.
trap "rm /usr/tmp/DTlist$$ /tmp/sed*$$" 0 1 2 15
cat > /tmp/sed.ex$$ << \EOF
/:$/h
/][ ]*_[_A-Z]/d
/^\[.* FUNC *UNDEF/ {
H
x
s/\n.*][ ]*/ /
s/[ 0][ 0x].*//
s/\(.*\): \(.*\)/\2 \1/p
s/.* //
s/[^:]$/&:/
h
}
EOF
cat > /tmp/sed.rel$$ << \EOF
/:$/h
/Text.*File/ {
/\/usr\/include\//d
s/^\[.*][ ]*//
s/[ 0].*/:/
/\.h:/d
s,/,,g
x
s/[^/]*://
x
H
x
s/\n//
h
}
/][ ]*_[_A-Z]/d
/^\[.* Undefined[ ]*Proc/ {
H
x
s/\n.*][ ]*/ /
s/[ 0][ 0x].*//
s/\(.*\): \(.*\)/\2 \1/p
s/.* //
s/[^:]$/&:/
h
}
EOF
# the c++filt demangles c++ names (and fortunately leaves intact
# the stuff after the white space); then we have to eliminate the
# stuff that it adds, when it demangles.
find $* -type f -follow -print | xargs file | \
sed -n '/dynamic executable/s/:.*//p' | \
xargs elfdump -Dt | \
sed -n -f /tmp/sed.ex$$ | \
/usr/lib/c++/c++filt | \
sed -e 's/.*::\([^:]*\)(/\1(/' -e 's/(.*)//' -e '/^~/d' > /usr/tmp/DTlist$$
find $* -type f -follow -print | xargs file | \
sed -n '/relocatable/s/:.*//p' | \
xargs odump -vt | \
sed -n -f /tmp/sed.rel$$ | \
/usr/lib/c++/c++filt | \
sed -e 's/.*::\([^:]*\)(/\1(/' -e 's/(.*)//' -e '/^~/d' -e 's,,/,g' \
-e s,/\./,/,g >> /usr/tmp/DTlist$$
# Can add another sed here to eliminate functions like ioctl that
# we don't want to see. For now, assume that if the file $HOME/skipfuncs
# exists, that we should eliminate those functions. It should consist
# of lines like (where it is a space and a tab inside the brackets)
# /^ioctl[ ]/d'
if [ -r $HOME/skipfuncs ]
then sed -f $HOME/skipfuncs /usr/tmp/DTlist$$ | sort -u -o /usr/tmp/INDEX
else sort -u /usr/tmp/DTlist$$ -o /usr/tmp/INDEX
fi